//
//  WFSelectedTableViewCell.m
//  FAKER
//
//  Created by Jianwei on 15/11/4.
//  Copyright © 2015年 YHLai. All rights reserved.
//

#import "WFSelectedTableViewCell.h"
#define HEAD_SECTION_URLSTRING @"http://iphone.myzaker.com/zaker/find_promotion.php?_appid=iphone"
#define ALL_DATA URLSTRING @"http://iphone.myzaker.com/zaker/apps_v3.php?_appid=iphone&_version=6.4&act=getAllAppsData"
#define BOTTOM_SECTION_URLSTRING @"http://iphone.myzaker.com/zaker/find.php?_appid=iphone&_version=6.4"
#import "FitHeader.h"
#import "AllHeader.h"
@implementation WFSelectedTableViewCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}
- (void)createCell
{
    _backView = [[BaseClassView alloc]init];
    [CONTENT_VIEW addSubview:_backView];
    
    _pic_imageView = [[BaseClassImageView alloc]init];
    [_backView addSubview:_pic_imageView];
    
    _titleLabel = [[BaseClassLabel alloc]init];
    _titleLabel.font = [UIFont fontWithBold:1 IPhone6sPlus:17 Iphone6s:15 Iphone5s:13 Iphone4s:11];
    [CONTENT_VIEW addSubview:_titleLabel];
   
    
    
    _stitleLabel = [[BaseClassLabel alloc]init];
    _stitleLabel.font = [UIFont fontWithBold:0 IPhone6sPlus:12 Iphone6s:10 Iphone5s:8 Iphone4s:8];
    _stitleLabel.textColor = [UIColor grayColor];
    [CONTENT_VIEW addSubview:_stitleLabel];
    
}
- (void)setModel:(WFSelectedModel *)model
{
    _model = model;
    [_pic_imageView sd_setImageWithURL:[NSURL URLWithString:[_model.block_info objectForKey:@"pic"]] placeholderImage:[UIImage imageNamed:@"PlaceHolder"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        _pic_imageView.image = [image imageWithColor:[UIColor RGBFromHexColor:[_model.block_info objectForKey:@"block_color"]]];
        if (NSUSERDEFAULTS_NIGHT) {
            _pic_imageView.image = [image imageWithColor:[UIColor lightGrayColor]];
        }
    }];
    
    _titleLabel.text = [_model.block_info objectForKey:@"title"];
    
    _stitleLabel.text = [_model.block_info objectForKey:@"stitle"];
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    _backView.frame = CGRectMake(10 * FITWIDTH, 10 * FITWIDTH, 80 * FITWIDTH, 80 * FITWIDTH);
    _backView.layer.borderWidth = .5;
    _backView.layer.borderColor = [UIColor RGBFromHexColor:[_model.block_info objectForKey:@"block_color"]].CGColor;
    if (NSUSERDEFAULTS_NIGHT) {
        _backView.layer.borderColor = [UIColor lightGrayColor].CGColor;
    }
    _backView.layer.cornerRadius = 40 * FITWIDTH;
    
    _pic_imageView.frame = CGRectMake(0, 8 * FITWIDTH, _backView.WIDTH, _backView.HEIGHT);
    _pic_imageView.layer.cornerRadius = 40 * FITWIDTH;
    
    _titleLabel.frame = CGRectMake(_pic_imageView.X + _pic_imageView.WIDTH + 30 * FITWIDTH, 30 * FITHEIGHT, 200 * FITWIDTH, 20 * FITHEIGHT);
    
    _stitleLabel.frame = CGRectMake(_titleLabel.X, _titleLabel.Y + _titleLabel.HEIGHT,  _titleLabel.WIDTH, _titleLabel.HEIGHT);
    if (NSUSERDEFAULTS_NIGHT) {
        _titleLabel.textColor = [UIColor grayColor];
        _stitleLabel.textColor = [UIColor grayColor];
    }
    
    
}
@end
